
package com.mego.tzadd.activitys;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.mego.tzadd.R;
import com.mego.tzadd.database.manager.SystemCenter;

import zuo.biao.library.base.BaseFragment;


public class Fragment2 extends BaseFragment  implements View.OnClickListener {
    private final String TAG = "Fragment2";

    //与Activity通信<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    /**
     * 创建一个Fragment实例
     *
     * @return
     */
    public static Fragment2 createInstance() {
        return new Fragment2();
    }

    //与Activity通信>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        setContentView(R.layout.fragment2);

        //功能归类分区方法，必须调用<<<<<<<<<<
        initView();
        initData();
        initEvent();
        //功能归类分区方法，必须调用>>>>>>>>>>

        return view;//返回值必须为view
    }

    private TextView tv_username;

    @Override
    public void initView() {//必须在onCreateView方法内调用
        tv_username = (TextView) findViewById(R.id.tv_username);
        tv_username.setText(SystemCenter.getInstance().username);
    }

    //示例代码>>>>>>>>>
    @Override
    public void initData() {//必须在onCreateView方法内调用
        //示例代码<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        //示例代码>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    }
    //Data数据区(存在数据获取或处理代码，但不存在事件监听代码)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    //Event事件区(只要存在事件监听代码就是)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    @Override
    public void initEvent() {//必须在onCreateView方法内调用
        findViewById(R.id.tv_zhzx).setOnClickListener(this);
        findViewById(R.id.tv_cjwt).setOnClickListener(this);
        findViewById(R.id.tv_wtfk).setOnClickListener(this);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
            case R.id.tv_zhzx:
                onZhzx();
                break;
            case R.id.tv_cjwt:
                onCjwt();
                break;
            case R.id.tv_wtfk:
                onWtfk();
                break;
        }
    }

    private void onZhzx() {
        startActivity(ProfileActivity.createIntent(getContext()));
    }

    private void onCjwt() {
        startActivity(CjwtActivity.createIntent(getContext()));
    }

    private void onWtfk() {
        startActivity(WtfkActivity.createIntent(getContext()));
    }

}